home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1005 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  73 lines

  1. Newsgroups: comp.unix.questions,comp.lang.c
  2. Path: news.sprintlink.net!eskimo!scs
  3. From: scs@eskimo.com (Steve Summit)
  4. Subject: Re: SIGBUS - What are the possible causes?
  5. X-Nntp-Posting-Host: eskimo.com
  6. Message-ID: <DKzFzF.IpK@eskimo.com>
  7. Sender: news@eskimo.com (News User Id)
  8. Organization: schmorganization
  9. References: <4ct4es$3k7@news1.wolfe.net>
  10. Date: Wed, 10 Jan 1996 20:38:02 GMT
  11.  
  12. [nonexistent group comp.unix.programming deleted]
  13.  
  14. In article <4ct4es$3k7@news1.wolfe.net>, mcguire@wolfe.net (McGuire) writes:
  15. > I am trying to compile a program under gcc 2.7.0 that works under the
  16. > native HP-UX 9.05 cc.  In one routine I get a SIGBUS error...  Does
  17. > anyone have any ideas as to what the possible causes of such an error
  18. > might be.
  19.  
  20. Here's the comp.lang.c answer, from an extended version of
  21. the comp.lang.c FAQ list (now available from Addison-Wesley,
  22. ISBN 0-201-84519-9):
  23.  
  24. 16.8:    What do "Segmentation violation" and "Bus error" mean?  What's a
  25.     "core dump"?
  26.  
  27. A:    These symptoms (and any similar messages having to do with
  28.     memory access violations or protection faults) generally mean
  29.     that your program tried to access memory it shouldn't have,
  30.     invariably as a result of improper pointer use.  Likely causes
  31.     are:
  32.  
  33.         inadvertent use of null pointers (see also questions 5.2
  34.         and 5.20)
  35.  
  36.         uninitialized, misaligned, or otherwise improperly
  37.         allocated pointers (see questions 7.1, 7.2, and 16.7)
  38.  
  39.         stale aliases to memory that has been relocated (see
  40.         question 7.29)
  41.  
  42.         corruption of the malloc arena (see question 7.19)
  43.  
  44.         attempts to modify read-only values (those declared const,
  45.         and string literals -- see question 1.32)
  46.  
  47.         mismatched function arguments, especially involving
  48.         pointers; two possibilities are scanf() (see question
  49.         12.12) and fprintf() (make sure it receives its first
  50.         FILE * argument)
  51.  
  52.     Under Unix, any of these problems almost invariably leads to a
  53.     "core dump": a file named core, [1] created in the current
  54.     directory, containing a memory image of the crashed process, for
  55.     debugging.
  56.  
  57.     The distinction between "Bus error" and "Segmentation Violation"
  58.     may or may not be significant; different versions of Unix
  59.     generate these signals under different sets of circumstances.
  60.     Roughly speaking, a segmentation violation indicates an attempt
  61.     to access memory which doesn't even exist, and a bus error
  62.     indicates an attempt to access memory in an illegal way (perhaps
  63.     due to an unaligned pointer; see question 16.7).
  64.  
  65.     See also questions 16.3 and 16.4.
  66.  
  67. __________
  68. 1.  Yes, the name "core" derives ultimately from old ferrite core
  69.     memories.
  70.  
  71.                         Steve Summit
  72.                         scs@eskimo.com
  73.